<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">项目回款信息</h4>
</div>
<div class="modal-body">
    <form role="form" class="validator_form" action="{:url('/Index/Project/Returned/add')}" id="addProjectReturnedForm" method="post">
        <input type="hidden" name="project_price" value="{$info.price?=$info.price}">
        <div class="box-body">
            <div class="col-md-6">
                <div class="form-group">
                    <label>项目名称</label>
                    <label class="form-control">{$info.title}</label>
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>项目合同金额</label>
                    <label class="form-control" id="project_price">{$info.price}</label>

                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>计划回款金额(万) </label>
                    <input type="text" name="plan_price" class="form-control" id="plan_price" required placeholder="计划回款比例">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>计划回款比例(%)</label>
                    <input type="text" name="plan_ratio" class="form-control" id="plan_ratio" required placeholder="计划回款金额">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>实际回款金额(万)</label>
                    <input type="text" name="real_price" class="form-control" id="real_price" required placeholder="实际回款金额">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>实际回款比例(%)</label>
                    <input type="text" name="real_ratio" class="form-control" id="real_ratio" required placeholder="实际回款比例">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>计划完成时间</label>
                    <input type="text" name="plan_time" class="form-control datepicker" id="plan_time" required placeholder="计划完成时间">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>实际完成时间</label>
                    <input type="text" name="real_time" class="form-control datepicker" id="real_time" required placeholder="实际完成时间">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>状态</label>
                    <select name="status" class="form-control" id="status" required>
                                    <option value="">请选择</option>
                                    {volist  name="code_status" id="vo"}
                                    <option value="{$vo.m_value}">{$vo.m_name}</option>
                                    {/volist}
                            </select>

                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>回款策略</label>
                    <input type="text" name="strategy" class="form-control" id="strategy" required placeholder="回款策略">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>风险</label>
                    <input type="text" name="risk" class="form-control" id="risk" required placeholder="风险">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label>协助用户</label>
                    <select name="assist_users[]" class="form-control select2" id="assist_users" required multiple>
                                 
                                    {volist  name="users" id="vo"}
                                    <option value="{$vo.id}">{$vo.nickname}</option>
                                    {/volist}
                            </select>
                </div>
            </div>
        </div>
        <div class="box-footer">
            <button type="submit" class="btn btn-primary">确认</button>
        </div>

    </form>
</div>

<script>
    $(function() {
        $("#plan_price").keyup(function() {
            var total_price = $("#project_price").text();
            total_price = parseFloat(total_price);
            var plan_price = $(this).val();
            var plan_ratio = 0;
            plan_price = parseFloat(plan_price);
            if (plan_price) {
                plan_ratio = (plan_price / total_price) * 100;
            }
            $("#plan_ratio").val(plan_ratio.toFixed(4));

        });


        $("#real_price").keyup(function() {
            var total_price = $("#project_price").text();
            total_price = parseFloat(total_price);
            var real_price = $(this).val();
            var real_ratio = 0;
            real_price = parseFloat(real_price);
            if (real_price) {
                real_ratio = (real_price / total_price) * 100;
            }
            $("#real_ratio").val(real_ratio.toFixed(4));

        });
    });
    $('.datepicker').datepicker({
        language: 'zh-CN',
        autoclose: true
    });
    $(".select2").select2();
    ajax_form_submit("addProjectReturnedForm");
</script>